"""
file: conftest.py
Author: 城下秋草
Desc: 
"""
import pytest
from playwright.sync_api import Playwright
from pom.util.util import Config

config = Config()
@pytest.fixture(scope="session")
def browser(playwright:Playwright):
    browser = playwright.chromium.launch(
        headless=config.get_config("headless"),
        slow_mo=config.get_config("slow_mo"),
        args=[f"--window-position={config.get_config("window-position")}"]
    )
    yield browser
    browser.close()

@pytest.fixture(scope="session")
def context(browser):
    width = int(config.get_config("view-port").split(",")[0])
    height = int(config.get_config("view-port").split(",")[1])
    context = browser.new_context(viewport={"width":width,"height":height})
    yield context
    context.close()

@pytest.fixture(scope="class")
def page(context):
    page = context.new_page()
    yield page
    page.close()